#Requires AutoHotkey v2.0 

global DynamicKey := ""      ;动态热键

SetCapsLockState("AlwaysOff")

#SuspendExempt  ; 从 Suspend 中豁免以下热键.
CapsLock:: OnlyInput.show()
+CapsLock:: ahkReload

; 动态热键
!b::{
  global DynamicKey 
  if IsObject(DynamicKey) {
    for i in DynamicKey { 
      if IsObject(i) {
        res := i()
        (res) && OnlyInput.parameter := res
      } else {
        specificBrowserRun(i) ; 这里是指定和切换浏览器的函数
      }
    }
  } else {
    Send(DynamicKey)
  } 
}
#SuspendExempt False  ; 禁用下面任何热键/热字符串的豁免.

;定义动态热键
defineSendKeys(key) {
  global DynamicKey := Array()
  len := OnlyInput.addressValue.Length
  if (len > 1) {                  ;判断是否是组合式命令
    for i in OnlyInput.addressValue {
      (A_Index < len) && DynamicKey.push(i)
    }
  } else {
    LocalMap.Has(key) ? DynamicKey.Push(LocalMap[key]) : DynamicKey := key
  }
}



;窗口管理快捷键
space & ]::increaseWindowOpacity() ;增加窗口不透明度
space & [::reduceWindowOpacity()  ;降低窗口不透明度
space & =::WinSetTransColor "off", "A"   ;不透明
space & q::WindowManager("q")   ;激活窗口
space & w::WindowManager("w")
space & e::WindowManager("e")
space & r::WindowManager("r")
space & z::WindowManager("z")
space & x::WindowManager("x")
space & c::WindowManager("c")
space & v::WindowManager("v")
Space & Shift::topOrMaxWindow("Shift")   ;窗口最大化  长按置顶
+Space::WinMoveFunction()     ;改变窗口位置


;启动powershell
!CapsLock::{
  Run "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
 if WinWaitActive("Terminal")
  Send "cd E:\Desktop `n"
  Send "^l"
}


;键位重映射
enter::enter 
tab::tab
space::space
; Enter & Tab::return         
; Space & Enter::return
space & d::esc
space & f::^z
space & g::^+z
space & i::end
space & o::home
space & h::left
space & j::down
space & k::up
space & l::right
space & `;::backspace
space & a::Delete
space & ,:: {
  if not GetKeyState("WheelUp")
    send "{WheelUp}"
} 
space & .:: {
  if not GetKeyState("WheelDown")
    Send "{WheelDown}"
}
space & m::^!f
Space & s::switchMouseMod

tab & w::!
tab & e::'
tab & r::%
tab & a::*
tab & s::+
tab & d::"
tab & f::=
tab & g::&
tab & z::^
tab & x::$
tab & c::`
tab & v::@
tab & u::_
tab & i::`{
tab & o::}
tab & h::|
tab & j::-
tab & k::(
tab & l::)
tab & `;::#
tab & n::\
tab & m::~
tab & ,::[
tab & .::]

enter & e::1
enter & a::2
enter & s::3
enter & d::4
enter & f::5
enter & i::0
enter & j::6
enter & k::7
enter & l::8
enter & `;::9
enter & g::^#left
enter & h::^#right
